package com.bd.rj.backstage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bd.rj.common.entity.Post;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 白世俊
 * @since 2025-01-03
 */
@Mapper
public interface PostMapper extends BaseMapper<Post> {
    @Select("select * from postweekly")
    Map<String,Object> getWeeklyPosts();
    @Select("select type as name,type_count as value from posttypeper")
    List<Map<String,Object>> getPostTypePer();
    void insertPostRecord(@Param("map") Map<String,Object> map);
//    @Select("select * from post where (company = #{post.company} or #{post.company} is null) and (postname =#{post.postname} or #{post.postname} is null) and (type = #{post.type} or #{post.type} is null) and (status = #{post.status} or #{post.type} is null)")
    IPage<Map> query(IPage<Map> page,@Param("post") Post post);

    @Select("select count(*) from post where uid = #{uid}")
    int getPostCount(@Param("uid") Long uid);

    List<Map<String,Object>> getPostPercentage(@Param("uid") Long uid);

}
